package com.sanhuo.security.service;

import com.sanhuo.security.RoleVO;
import com.sanhuo.security.dao.RoleMapper;
import com.sanhuo.security.entity.Role;
import com.sanhuo.triild.Basic.BaseMapper;
import com.sanhuo.triild.Basic.BaseService;
import com.sanhuo.triild.annotation.MapperWire;
import com.sanhuo.utils.basic.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class RoleService extends BaseService<Role> {
    @MapperWire
    private RoleMapper roleMapper;
    @Autowired
    private PermitService permitService;


    @Override
    public BaseMapper<Role> getBaseMapper() {
        return roleMapper;
    }

    public RoleVO detail(String roleId) throws IllegalAccessException {
        Role role = findById(roleId);
        RoleVO result = new RoleVO();
        BeanUtil.copyBean(role, result);
        result.setPermit(permitService.findByRole(role.getId()));
        return result;
    }


}
